class Product < ActiveRecord::Base
  validates :Name, :presence  => true
  validates :category_id, :presence => true
  
  	def self.searchDrink(searchDrink)
	  	if searchDrink
	    	find(:all, :conditions => ['Name LIKE ?', "%#{searchDrink}%"])
	  	else
			find(:all)
		end
	end

	def self.searchCategory(searchCategory)
	  	if searchCategory
	    	#search22 = "%" + searchCategory + "%"
			#find_by_sql ["SELECT products.* FROM products, categories 
			#	WHERE products.category_id=categories.category_id AND categories.Name LIKE?", search22]
			find(:all, :conditions => ['category_id LIKE?', "#{searchCategory}"])
	  	else
			find(:all)
		end
	end

	

end
